import {defineStore} from "pinia";
//pinia仓库写法：组合式API、选择式API写法

import {reqHospitalDepartment, reqHospitalDetail} from "@/api/hospital/index.ts"
import type {DepartmentResponseData, HospitalDetail} from "@/api/hospital/type.ts";
import {DetailState} from "@/store/modules/interface";

const useDetailStore = defineStore('Detail',{
    state:():DetailState=>{
        return {
            //医院详情数据
            hospitalInfo:({} as HospitalDetail),
            departmentArr:[]
        }
    },
    actions:{
    //获取医院详情的方法
        async getHospital(hoscode:string){
           let result:HospitalDetail =  await reqHospitalDetail(hoscode);
           if(result.code==200){
               this.hospitalInfo = result.data;
           }
        },
        async getDepartment(hoscode:string){
            let result:DepartmentResponseData = await reqHospitalDepartment(hoscode);
            if(result.code==200){
                this.departmentArr = result.data;
            }
        }
    },
    getters:{

    }
})

export default useDetailStore
